package com.gzy.gameserver;

import java.awt.geom.Point2D;
import java.sql.ResultSet;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.gamalocus.sgs.services.mysql.MySQLManager;
import com.sun.sgs.app.AppContext;

public class NPCPawn extends Pawn {

	/**The version of the serialized form of this class */
	private static final long serialVersionUID = 1L;
	
	private static final Logger logger = Logger.getLogger(Player.class.getName());

	protected int m_npcId = -1;
	protected NPCPawn(String name, int npc_id, 
			Point2D.Float location)
	{
		super(name);
		this.m_location.x = location.x;
		this.m_location.y = location.y;
		this.m_npcId = npc_id;
		
		this.m_life = this.m_maxLife = 1000000000;
	}
	
	public int getNpcId()
	{
		return this.m_npcId;
	}
	
	public void enter(World world)
	{
		logger.log(Level.INFO, "{0} enter {1}", new Object[]{this, world});
		
		world.addNPCPawn(this);
		
		setWorld(world);
	}
	
	public void leave()
	{
		logger.log(Level.INFO, "{0} leave {1}", new Object[]{this, getWorld()});	
		this.getWorld().removeNPCPawn(this);
		setWorld(null);
	}
}
